<style lang="less">
@import './historicDetail.less';
@import '../../../styles/single-common.less';
</style>
<template>
    <div class="search wh-100 " style="background-color: white">
      <div class="h-10  pt-12 pl-12 pr-12 bor-base-b">
          <div class="edit-head d-flex-between-center">
            <div class="fs-16 fw-7">登记历史</div>
            <el-button @click="close">返回</el-button>
          </div>
      </div>
      <div v-ref-height="refHeight" class="h-80 mt-8">
        <Table :loading="loading" :columns="columns" :height="refHeight.value" :data="data" ref="table"></Table>
      </div>
<!--        <Card style="margin-bottom: 10px">-->
<!--            -->
<!--            <Row style="position: relative">-->
<!--            </Row>-->
<!--        </Card>-->
    </div>
</template>

<script>

import {
    obtainEmploymentStatusDataAPI
} from '../../../api/bys';
import { getJyqxRecordByidCard } from '../../../api/bys/jyqx/jyqx';
import { getDictDataByType } from '@/api';
export default {
    name: 'historic_detail',
    props: {
        idCard: String,
        tableId: String,
        type: String
    },
    data() {
        return {
            loading: false, // 表单加载状态
            loadingImg: false,
            oneTypeDicts: [],
            refHeight:{value:0},
            columns: [
                {
                    title: '毕业类别',
                    key: 'onetype',
                    minWidth: 120,
                    sortable: false,
                    render: (h, params) => {
                        if (params.row.onetype === '5') {
                            return h('span', '暂未登记或上报');
                        } else {
                            let arr = this.oneTypeDicts.filter(e => e.value == params.row.onetype);
                            return h('span', arr && arr.length > 0 ? arr[0].title : '');
                        }
                    }
                },
                {
                    title: '毕业去向代码',
                    key: 'type',
                    minWidth: 120,
                    sortable: false,
                },
                {
                    title: '单位名称',
                    key: 'dwmc',
                    minWidth: 120,
                    sortable: false
                },
                {
                    title: '操作时间',
                    key: 'createTime', //updateTime /dueTime
                    minWidth: 120,
                    sortable: true
                },
                {
                    title: '操作人 ',
                    key: 'opr',
                    align: 'center',
                    sortable: false,
                    minWidth: 180
                },
                {
                    title: '操作',
                    key: 'op',
                    align: 'center',
                    sortable: false,
                    minWidth: 180,
                    render: (h, params) => {
                        if (params.row.op == 0) {
                            return h('op', '编辑');
                        } else if (params.row.op == 1) {
                            return h('op', '学生申请');
                        } else if (params.row.op == 2) {
                            return h('op', '撤回');
                        } else if (params.row.op == 3) {
                            return h('op', '作废');
                        } else if (params.row.op == 4) {
                            return h('op', '通过');
                        } else if (params.row.op == 5) {
                            return h('op', '驳回');
                        } else if (params.row.op == 6) {
                            return h('op', '学校修改');
                        }else if (params.row.op == 7) {
                            return h('op', '学院修改');
                        }else if (params.row.op == 8) {
                            return h('op', '导入');
                        }
                    }
                },
            ],
            data: [],
            id: '',
            imgUrl: '',
            backRoute: ''
        };
    },
    methods: {
        getDictDataType() {
            getDictDataByType('qx').then(res => {
                if (res.success) {
                    this.oneTypeDicts = res.result;
                }
            });
        },
        init() {
            if (this.$route.query.id) {
                console.log(this.$route.query, '1234567');
                this.id = this.$route.query.id;
                this.backRoute = this.$route.query.backRoute;
            } else {
                console.log(this.idCard, '8');
                this.idCard = this.idCard;
            }
            this.getDataList();
            this.getDictDataType();
        },

        getDataList() {
            this.loading = true;
            getJyqxRecordByidCard({ idCard: this.idCard })
                .then(res => {
                    this.loading = false;
                    if (res.success) {
                        this.data = res.result;
                        // if (!res.result || res.result.length == 0) {
                        //     this.$Modal.info({
                        //         title: '未找到该记录审批历史数据',
                        //         content: '历史数据可能已被删除'
                        //     });
                        // }
                    }
                })
                .finally(() => {
                    this.loading = false;
                });
        },
        // 关闭当前页面
        close() {
            if (this.$route.query.id) {
                this.$store.commit('removeTag', 'historic_detail');
                sessionStorage.pageOpenedList = JSON.stringify(this.$store.state.app.pageOpenedList);
                this.$router.push({
                    name: this.backRoute
                });
            } else {
                this.$emit('close', true);
            }
        }
    },
    mounted() {
        this.init();
        console.log(this.type, '');
    },
    watch: {
        // 监听路由变化
        $route(to, from) {
            if (to.name == 'historic_detail') {
                this.init();
            }
        }
    }
};
</script>
